package com.ctg.payroll2.service.social.impl;

import java.util.List;

import com.ctg.payroll2.bean.filter.social.PbCommsocialMasterFilter;
import com.ctg.payroll2.bean.filter.social.PbSocialMasterFilter;
import com.ctg.payroll2.bean.po.social.PbCommsocialDetail;
import com.ctg.payroll2.bean.po.social.PbCommsocialMaster;
import com.ctg.payroll2.dao.social.RecomTemplateDao;
import com.ctg.payroll2.service.BaseService;
import com.ctg.payroll2.service.social.RecomTemplateService;
import com.ctg.platform.util.Page;
/**
 * 推荐社保模板service实现
 * @author 鲁力 2009-9-7 上午09:54:50
 *
 */
@SuppressWarnings("unchecked")
public class RecomTemplateServiceImpl extends BaseService implements RecomTemplateService {
	private RecomTemplateDao dao;
	public void deletePbCommsocialById(Long detailId) {
		dao.deletePbCommsocialById(detailId);
	}

	public void deletePbCommsocialByIds(String detailIds) {
		dao.deletePbCommsocialByIds(detailIds);
	}

	public void deleteRecomTemplateById(Long templateId) {
		dao.fakeDeleteRecomTemplateById(templateId);
	}

	public void deleteRecomTemplateByIds(String templateIds) {
		dao.deleteRecomTemplateByIds(templateIds);
	}

	public PbCommsocialMaster getPbSocialMasterById(Long id) {
		if (id == null) {
			return null;
		}
		PbCommsocialMaster bean = new PbCommsocialMaster();
		List<PbCommsocialMaster> list = dao.getPbSocialMasterListById(id);
		if (list.size() == 1) {
			bean = list.get(0);
			bean.setBeanList(dao.getSocialItemByTemplateId(id));
		}
		return bean;
	}

	public void insertPbCommsocialDetail(String details, Long socialTemplateId) {
		PbCommsocialDetail detail = new PbCommsocialDetail();
		detail.setTemplate_id(socialTemplateId);
		String[] str = details.split(",");
		for (int i = 0; i < str.length; i++) {
			detail.setSocial_security_id(Long.parseLong(str[i]));
			dao.insertPbCommsocialDetail(detail);
		}
	}

	public void insertRecomTemplate(PbCommsocialMaster pbCommsocialMaster) {
		dao.insertRecomTemplate(pbCommsocialMaster);
	}

	public Page queryRecomTemplate(PbCommsocialMasterFilter filter) {
		return dao.queryRecomTemplate(filter);
	}

	public Page querySocialItemAll(PbSocialMasterFilter filter) {
		return dao.querySocialItemAll(filter);
	}

	public void updateRecomTemplate(PbCommsocialMaster pbCommsocialMaster) {
		dao.updateRecomTemplate(pbCommsocialMaster);
	}

	/**
	 * @param dao 设置dao
	 */
	public void setDao(RecomTemplateDao dao) {
		this.dao = dao;
	}
}
